#include <stdio.h>
#include <unistd.h>
#include <string.h>

//自定义枚举常量
enum
{
  Success=0,
  Div_Zero,
  Mod_Zero,

};
const char* CodeErr(int code)
{
  switch(code)
  {
    case Success:
      return "Success";
    case Div_Zero:
      return "div zero";
    case Mod_Zero:
      return "mod zero";
    default:
      return "unknown";
  }
}
int exit_code = Success;

int Div(int x,int y)
{
  if(y==0)
  {
    exit_code=Div_Zero;
    return -1;
  }
  else
  {
    return x/y;
  }
}
int main()
{
  int ret=Div(0,10);
  printf("ret=%d [%s]\n",ret,CodeErr(exit_code));
  ret=Div(10,0);
  printf("ret=%d [%s]\n",ret,CodeErr(exit_code));
  return exit_code;
//  for(int errcode=0;errcode<=255;errcode++)
//  {
//    printf("%d:%s\n",errcode,strerror(errcode));
//  }
//  printf("i am a process, pid:%d,ppid:%d\n",getpid(),getppid());
//  sleep(2);
//  return 100;
}
